<template>
	<view class="content">
		<view class="listBox">
			<view class="item" v-for="(item, i) in list" :key="i">
				<view class="tit">{{item.title}}</view>
				<uni-icons type="download" size="24" color="#4EB0FF" @click="downLoadFile(item.knowledge_files)"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	import common from '@/static/js/common';

	export default {
		data() {
			return {
				list: [],
			}
		},
		mounted() {
			this.getKnowledgeInfo()
		},
		methods: {
			getKnowledgeInfo() {
				let that = this;
				common.api({
					method: 'GET',
					url: '/mobile/index/knowledge',
					success:(res) => {
						if (res.code != 0) {
							uni.showToast({ title: res.msg, icon: 'none' });
							return false;
						}
						that.list = res.data
					}
				});
			},
			downLoadFile(url) {
				let a = document.createElement('a');
				a.href = getApp().globalData.DOMAIN+url;
				a.style.display = 'none';
				document.body.appendChild(a);
				a.click();
				document.body.removeChild(a);
			}
		}
	}
</script>

<style lang="less" scoped>
	.listBox {
		background-color: #fff;
		margin-top: 30rpx;
		.item {
			height: 88rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 3vw;
			&+.item {
				border-top: 2rpx solid #eee;
			}
			.tit {
				display: flex;
				align-items: center;
				.uni-icons {
					margin-right: 10rpx;
				}
			}
			.arrow {
				height: 30rpx;
			}
		}
	}
</style>
